package com.love.cloud.admin.controller;

import com.love.cloud.admin.api.entity.SysCustomGroup;
import com.love.cloud.admin.api.vo.CustomGroupChangeVo;
import com.love.cloud.admin.service.SysCustomGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 自定义组
 * @author hongdongqu
 */
@RestController
@RequestMapping("/custom/group")
@Api(tags = "自定义组")
public class CustomGroupController {
    @Resource
    private SysCustomGroupService sysCustomGroupService;

    @PostMapping("/add")
    @ApiOperation(value = "添加")
    public Object add(@RequestBody SysCustomGroup sysCustomGroup){
        return sysCustomGroupService.saveData(sysCustomGroup);
    }

    @PutMapping("/update")
    @ApiOperation(value = "更新")
    public Object update(@RequestBody SysCustomGroup sysCustomGroup){
        return sysCustomGroupService.updateById(sysCustomGroup);
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除")
    public Object delete(@PathVariable Long id){
        return sysCustomGroupService.removeById(id);
    }

    @PostMapping("/change")
    @ApiOperation(value = "人员变更")
    public Object change(@Valid @RequestBody CustomGroupChangeVo customGroupChangeVo){
        return sysCustomGroupService.change(customGroupChangeVo);
    }
}
